#!/bin/bash

#set -x
#set -e

# require GOPATH

if [ ! $GOPATH ]; then
  echo "Need to install go first, then set GOPATH env!"
  exit 2
fi

usage() {
  echo "gorun [groupname@version]"
  echo "e.g. gorun github.com/pborman/uuid@v1.2.0"
  echo ""
}

PACKAGE=$1

if [ ! $PACKAGE ]; then
  usage
  exit 1
fi

go env -w GOPROXY=http://106.13.250.41/repository/go-public/,direct
rm -rf $GOPATH/pkg/mod/*
SUM="sum:`go mod download -json $PACKAGE | grep '"Sum"' | awk -F' ' '{print $2}'`"
GOMODSUM="gomodsum:`go mod download -json $PACKAGE | grep '"GoModSum"' | awk -F' ' '{print $2}'`"
echo $SUM $GOMODSUM



